<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\components\ListWidget;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\DoctorSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Doctors';
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="admin-content">
    <div class="admin-content-body">
        <div class="am-cf am-padding am-padding-bottom-0">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">医生列表</strong> / <small>Table</small></div>
        </div>
        <hr>
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <button type="button" class="am-btn am-btn-default" id="doc-add"><span class="am-icon-plus"></span> 新增</button>
                        <button type="button" class="am-btn am-btn-default"><span class="am-icon-save"></span> 保存</button>
                        <button type="button" class="am-btn am-btn-default"><span class="am-icon-archive"></span> 审核</button>
                        <button type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>
                    </div>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
                <div class="am-form-group">
                    <select data-am-selected="{btnSize: 'sm'}">
                        <option value="option1">所有类别</option>
                        <option value="option2">IT业界</option>
                        <option value="option3">数码产品</option>
                        <option value="option3">笔记本电脑</option>
                        <option value="option3">平板电脑</option>
                        <option value="option3">只能手机</option>
                        <option value="option3">超极本</option>
                    </select>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
                <div class="am-input-group am-input-group-sm">
                    <input type="text" class="am-form-field">
          <span class="am-input-group-btn">
            <button class="am-btn am-btn-default" type="button">搜索</button>
          </span>
                </div>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-check"><input type="checkbox" /></th>
                            <th class="table-id">ID</th>
                            <th class="table-title">医生姓名</th>
                            <th class="table-title">用户名称</th>
                            <th class="table-type">职务名称</th>
                            <th class="table-author am-hide-sm-only">应约次数</th>
                            <th class="table-date am-hide-sm-only">关注次数</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach($doctorData as $k => $v){ ?>
                        <tr>
                            <td><input type="checkbox" value="<?=$v['id']?>" /></td>
                            <td value="<?=$v['id']?>" class="data-id"><?=$v['id']?></td>
                            <td value="<?=$v['name']?>" class="data-name"><?=$v['name']?></td>
                            <td value="<?=$v['username']?>" class="data-username"><a href="#"><?=$v['username']?></a></td>
                            <td value="<?=$v['title']?>" class="data-title"><?=$v['title']?></td>
                            <td value="<?=$v['response_times']?>" class="am-hide-sm-only data-response_times"><?=$v['response_times']?></td>
                            <td value="<?=$v['follow_numbers']?>" class="am-hide-sm-only data-follow_numbers"><?=$v['follow_numbers']?></td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                                            <span class="am-icon-pencil-square-o"></span>
                                            <a href="<?php echo \yii\helpers\Url::toRoute(['doctor/update','id'=>$v['id']]);?>">编辑</a>
                                        </button>
                                        <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only data-del">
                                            <span class="am-icon-trash-o"></span> 删除
                                        </button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <div class="am-cf">
                        共 2 条记录
                        <div class="am-fr">
                            <ul class="am-pagination">
                                <li class="am-disabled"><a href="#">«</a></li>
                                <li class="am-active"><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li><a href="#">»</a></li>
                            </ul>
                        </div>
                    </div>
            </div>
        </div>
    </div>

    <!--删除按钮-->
    <div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">好头发平台</div>
            <div class="am-modal-bd">
                确定要删除这条记录吗？
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn" data-am-modal-cancel>取消</span>
                <span class="am-modal-btn" data-am-modal-confirm>确定</span>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function() {
            $('.data-del').on('click', function() {
                var temp = $(this).parent().parent().parent();
                var id = temp.siblings('.data-id').attr('value');
                //console.log(id);
                $('#my-confirm').modal({
                    relatedTarget: this,
                    onConfirm: function(options) {
                        $.post('delete-doctor',{id:id},function(data){
                            console.log(data);
                        });
                    },
                    onCancel: function() {
                        console.log('console');
                    }
                });
            });
        });
    </script>
</div>
